////
////  BiPullRefreshViewController.m
////  GottaWash
////
////  Created by bindu on 14-8-28.
////  Copyright (c) 2014年 QiHe. All rights reserved.
////
//
//#import "BiPullRefreshViewController.h"
//#import "EGORefreshTableHeaderView.h"
//#import "EGORefreshTableFooterView.h"
//
//@interface BiPullRefreshViewController()<EGORefreshTableDelegate, UIScrollViewDelegate>
//{
//    //EGOHeader
//    EGORefreshTableHeaderView *_refreshHeaderView;
//    //EGOFoot
//    EGORefreshTableFooterView *_refreshFooterView;
//    //
//    BOOL _reloading;
//}
//@end
//
//@implementation BiPullRefreshViewController
//
////初始化
//- (void)viewDidLoad
//{
//    [super viewDidLoad];
//    
//    [self addTestView];
//    
//    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, _naviBarView.frame.origin.y+_naviBarView.frame.size.height, MAIN_SCREEN_WIDTH, MAIN_SCREEN_HEIGHT-(_naviBarView.frame.origin.y+_naviBarView.frame.size.height)) style:UITableViewStylePlain];
//    _tableView.delegate = self;
//    _tableView.dataSource = self;
//    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//    [self.view addSubview:_tableView];
//    [_tableView release];
//    
//    [self createHeaderView];
//    [self setFooterView];
//    
//	[self refreshHeaderFoterView];
//}
//
//- (void)refreshHeaderFoterView
//{
//	_reloading = NO;
//    
//	if (_refreshHeaderView)
//    {
//        [_refreshHeaderView resetView:_tableView];
//    }
//    if (_refreshFooterView)
//    {
//        [_refreshFooterView resetView:_tableView];
//        [self setFooterView];
//    }
//}
//
//- (void)didReceiveMemoryWarning
//{
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}
//
////＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝
////初始化刷新视图
////＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝
//#pragma mark
//#pragma methods for creating and removing the header view
//-(void)createHeaderView
//{
//    if (_refreshHeaderView && [_refreshHeaderView superview])
//    {
//        [_refreshHeaderView removeFromSuperview];
//    }
//    
//	_refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:
//                          CGRectMake(0.0f, 0.0f - self.view.bounds.size.height,
//                                     self.view.frame.size.width, self.view.bounds.size.height)];
//    _refreshHeaderView.delegate = self;
//	[_tableView addSubview:_refreshHeaderView];
//    [_refreshHeaderView release];
//    
//    [_refreshHeaderView refreshLastUpdatedDate];
//}
//
//-(void)removeHeaderView
//{
//    if (_refreshHeaderView && [_refreshHeaderView superview])
//    {
//        [_refreshHeaderView removeFromSuperview];
//    }
//    _refreshHeaderView = nil;
//}
//
//-(void)setFooterView
//{
//    CGFloat height = MAX(_tableView.contentSize.height, _tableView.frame.size.height);
//    if (_refreshFooterView && [_refreshFooterView superview])
//    {
//        // reset position
//        _refreshFooterView.frame = CGRectMake(0.0f,
//                                              height,
//                                              _tableView.frame.size.width,
//                                              self.view.bounds.size.height);
//    }
//    else
//    {
//        // create the footerView
//        _refreshFooterView = [[EGORefreshTableFooterView alloc] initWithFrame:
//                              CGRectMake(0.0f, height,
//                                         _tableView.frame.size.width, self.view.bounds.size.height)];
//        _refreshFooterView.delegate = self;
//        [_tableView addSubview:_refreshFooterView];
//        [_refreshFooterView release];
//    }
//    
//    if (_refreshFooterView)
//    {
//        [_refreshFooterView refreshLastUpdatedDate];
//    }
//}
//
//-(void)removeFooterView
//{
//    if (_refreshFooterView && [_refreshFooterView superview])
//    {
//        [_refreshFooterView removeFromSuperview];
//    }
//    
//    _refreshFooterView = nil;
//}
//
//#pragma mark-
//#pragma mark force to show the refresh headerView
//-(void)showRefreshHeader:(BOOL)animated
//{
//	if (animated)
//	{
//		[UIView beginAnimations:nil context:NULL];
//		[UIView setAnimationDuration:0.2];
//		_tableView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);
//        // scroll the table view to the top region
//        [_tableView scrollRectToVisible:CGRectMake(0, 0.0f, 1, 1) animated:NO];
//        [UIView commitAnimations];
//	}
//	else
//	{
//        _tableView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);
//		[_tableView scrollRectToVisible:CGRectMake(0, 0.0f, 1, 1) animated:NO];
//	}
//    
//    [_refreshHeaderView setState:EGOOPullRefreshLoading];
//}
//
////===============
////刷新delegate
//#pragma mark -
//#pragma mark data reloading methods that must be overide by the subclass
//-(void)beginToReloadData:(EGORefreshPos)aRefreshPos
//{
//	//  should be calling your tableviews data source model to reload
//	_reloading = YES;
//    
//    if (aRefreshPos == EGORefreshHeader)
//    {
//        // pull down to refresh data
//        [self performSelector:@selector(refreshView) withObject:nil afterDelay:0.1];
//    }
//    else if(aRefreshPos == EGORefreshFooter)
//    {
//        // pull up to load more data
//        [self performSelector:@selector(getNextPageView) withObject:nil afterDelay:0.1];
//    }
//	// overide, the actual loading data operation is done in the subclass
//}
//
//#pragma mark -
//#pragma mark method that should be called when the refreshing is finished
//- (void)finishReloadingData
//{
//	//  model should call this when its done loading
//	_reloading = NO;
//    
//	if (_refreshHeaderView)
//    {
//        [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:_tableView];
//    }
//    
//    if (_refreshFooterView)
//    {
//        [_refreshFooterView egoRefreshScrollViewDataSourceDidFinishedLoading:_tableView];
//        [self setFooterView];
//    }
//}
//
//#pragma mark -
//#pragma mark UIScrollViewDelegate Methods
//- (void)scrollViewDidScroll:(UIScrollView *)scrollView
//{
//	if (_refreshHeaderView)
//    {
//        [_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
//    }
//	
//	if (_refreshFooterView)
//    {
//        [_refreshFooterView egoRefreshScrollViewDidScroll:scrollView];
//    }
//}
//
//- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
//{
//	if (_refreshHeaderView)
//    {
//        [_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];
//    }
//	
//	if (_refreshFooterView)
//    {
//        [_refreshFooterView egoRefreshScrollViewDidEndDragging:scrollView];
//    }
//}
//
//#pragma mark -
//#pragma mark EGORefreshTableDelegate Methods
//- (void)egoRefreshTableDidTriggerRefresh:(EGORefreshPos)aRefreshPos
//{
//	[self beginToReloadData:aRefreshPos];
//}
//
//- (BOOL)egoRefreshTableDataSourceIsLoading:(UIView*)view
//{
//	return _reloading; // should return if data source model is reloading
//}
//
//// if we don't realize this method, it won't display the refresh timestamp
////- (NSDate*)egoRefreshTableDataSourceLastUpdated:(UIView*)view
////{
////	return [NSDate date]; // should return date data source was last changed
////}
//
////刷新调用的方法
//-(void)refreshView
//{
//    [self onPullRefreshViewRefresh];
//}
////加载调用的方法
//-(void)getNextPageView
//{
//    [self onPullRefreshViewGetNextPage];
//}
//
//#pragma mark PullRefreshViewController
//- (void)onPullRefreshViewRefresh
//{
//    
//}
//- (void)onPullRefreshViewGetNextPage
//{
//    
//}
//
//#pragma mark - UITableViewDataSource
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    return 0;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    static NSString *reuseIdetify = @"PullRefreshTableViewCell";
//    UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:reuseIdetify];
//    
//    if (!cell)
//    {
//        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdetify];
//        cell.accessoryType = UITableViewCellAccessoryNone;
//        
//    }
//    
//    return cell;
//}
//
//
//@end
